<?php
/************************************
*   熊店
*   @file:/server/bearshop/__include/data_model/mod_user.php
*   @intro:
*   @author:new_shop
*   @email:new_shop@163.com    
*   @date:Fri Feb 12 10:27:58 CST 2010
************************************/

class mod_member_apply extends data_model 
{
    
    public function __construct($db_config)
    {
        parent::__construct($db_config);
        $this->_table = 'tl_member_apply';
    }

    public function create($data)
    {
        $this->start(K5_DATAMOD_NOHASH);
        
        $this->set('name' , $data['name']);
        $this->set('company' , $data['company']);
        $this->set('mobile' , $data['mobile']);
        $this->set('email' , $data['email']);
        $this->set('fax' , $data['fax']);
        $this->set('message' , $data['message']);
        $this->set('visit_hiStory' , serialize($data['visit_history']));
        
        $this->set('ctime' , time());
        $this->set('cip' , K::get_ip());
        
        return $this->insert();
        
    }
    
    public function get_list($page , $stat = K_COMMON_NO, $pagesize = 10)
    {
        $this->start(K5_DATAMOD_NOHASH);
        
        $this->set_condition('stat='.$stat);
        return $this->fetch_multi(null , 'id DESC' , $page , $pagesize);
    }
    
    public function get_by_id($id)
    {
        $this->start(K5_DATAMOD_NOHASH);
        $this->set_condition('id='.$id);
        return $this->fetch();
    }
    
    public function edit_stat($stat , $ids)
    {
        $sIds = implode(',' , (array)$ids);
        $this->start(K5_DATAMOD_NOHASH);
        $this->set_condition('id in ('.$sIds.')');
        $this->set('stat' , $stat);
        return $this->update();
    }
    
    public function del_by_ids($ids)
    {
        $sIds = implode(',' , (array)$ids);
        $this->start(K5_DATAMOD_NOHASH);
        $this->set_condition('id in ('.$sIds.')');
        return $this->delete();
    }
}
?>